package com.my.study.chatting.controller;

import com.my.study.chatting.MessageDTO;
import com.my.study.chatting.service.WebSocketService;
import com.my.study.entity.vo.ResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 聊天专用
 */
@RestController
@RequestMapping("/chat")
public class WebSocketController {

    @Autowired
    private WebSocketService webSocketService;

    @GetMapping("/sendAll")
    public ResponseVO sendAllMessage(){
        webSocketService.sendAllMessage("success");
        return ResponseVO.success();
    }

    @PostMapping("/send-to-user")
    public ResponseVO sendMessage(@RequestBody MessageDTO message){
        webSocketService.sendMessage(message);
        return ResponseVO.success();
    }

}
